package com.ads.orm.db.model;

import java.util.List;

import com.abs.orm.model.SuperModel;

public class Table implements SuperModel {

	/**
	 *
	 */
	private static final long serialVersionUID = -837588151753396207L;
	private String tableName;
	private String alias;
	private List<Column> columns;
	private String primaryKeyColumnName;

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public String getAlias() {
		return alias;
	}

	public void setAlias(String alias) {
		this.alias = alias;
	}

	public List<Column> getColumns() {
		return columns;
	}

	public void setColumns(List<Column> columns) {
		this.columns = columns;
	}

	public String getPrimaryKeyColumnName() {
		return primaryKeyColumnName;
	}

	public void setPrimaryKeyColumnName(String primaryKeyColumnName) {
		this.primaryKeyColumnName = primaryKeyColumnName;
	}

	public Column getPKColumn() {
		for (Column column : getColumns()) {
			if (column.getColumnName().equalsIgnoreCase(getPrimaryKeyColumnName()))
				return column;
		}
		return null;
	}
}
